import React, { Component } from "react";

interface CounterState {
  count: number;
}

class Counter extends Component<{}, CounterState> {
  state: CounterState = { count: 0 };

  increment = () => this.setState(({ count }) => ({ count: count + 1 }));
  decrement = () => this.setState(({ count }) => ({ count: count - 1 }));

  render() {
    return (
      <div>
        <h1 data-testid="counter">{this.state.count}</h1>
        <button data-testid="button-up" onClick={this.decrement}>
          -
        </button>
        <p>{this.state.count}</p>
        <button data-testid="button-down" disabled onClick={this.increment}>
          +
        </button>
      </div>
    );
  }
}

export default Counter;
